from django.conf.urls import url
from rest_framework.routers import DefaultRouter
from rest_framework_jwt.views import obtain_jwt_token

from . import views
urlpatterns = [
    url(r'users/$', views.UserView.as_view()),      # 注册功能
    url(r'^usernames/(?P<username>\w{5,20})/count/$', views.UsernameCountView.as_view()),   # 不重名
    url(r'^mobiles/(?P<mobile>1[3-9]\d{9})/count/$', views.MobileCountView.as_view()),      # 手机号不重复
    url(r'authorizations/$', obtain_jwt_token),     # 登录认证
    url(r'user/$', views.UserDetailView.as_view()),   # 获取单个用户
    url(r'^email/$', views.EmailView.as_view()),  # 设置邮箱
    url(r'^emails/verification/$', views.VerifyEmailView.as_view()),  # 验证token的有效性

]

router = DefaultRouter()
router.register(r'addresses', views.AddressViewSet, base_name='addresses')
urlpatterns += router.urls


# import rest_framework_jwt.utils.jwt_response_payload_handler
# import rest_framework_jwt.utils.jwt_response_payload_handler'